From afbe7e29106f9126c53a0c533ab007aae1f81139 Mon Sep 17 00:00:00 2001
From: Andriy Grytsenko <andrej@rep.kiev.ua>
Date: Sat, 17 Nov 2012 15:02:15 +0200
Subject: [PATCH 13/22] [#3587571]Ctrl+A should select all depending on focus.

The commit changes bahavior of Ctrl+A: it does not select all files in
the active view anymore but does it only if focus in in the view.
If focus is on some editable (i.e. path entry) it will select all in there.
---
 src/gtk/fm-folder-view.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/gtk/fm-folder-view.c b/src/gtk/fm-folder-view.c
index fe65e9f..d7fa53e 100644
--- a/src/gtk/fm-folder-view.c
+++ b/src/gtk/fm-folder-view.c
@@ -1035,7 +1035,15 @@ static void on_rm(GtkAction* act, FmFolderView* fv)
 
 static void on_select_all(GtkAction* act, FmFolderView* fv)
 {
-    fm_folder_view_select_all(fv);
+    GtkMenu *popup = g_object_get_qdata(G_OBJECT(fv), popup_quark);
+    GtkWidget *win = gtk_menu_get_attach_widget(popup);
+    GtkWidget *focus = gtk_window_get_focus(GTK_WINDOW(win));
+
+    /* check if we are inside the view; for desktop focus will be NULL */
+    if(focus == NULL || gtk_widget_is_ancestor(focus, GTK_WIDGET(fv)))
+        fm_folder_view_select_all(fv);
+    else if(GTK_IS_EDITABLE(focus)) /* fallback for editables */
+        gtk_editable_select_region((GtkEditable*)focus, 0, -1);
 }
 
 static void on_invert_select(GtkAction* act, FmFolderView* fv)
-- 
1.8.0.1

